﻿using System;
using System.ComponentModel;
using System.Runtime.InteropServices;
using Teigha.Core;

namespace Teigha.TD
{
	public class OdDbSelectionSet : OdSelectionSet
	{
		[EditorBrowsable(EditorBrowsableState.Never)]
		public OdDbSelectionSet(IntPtr cPtr, bool cMemoryOwn) : base(TD_DbPINVOKE.OdDbSelectionSet_SWIGUpcast(cPtr), cMemoryOwn)
		{
			this.swigCPtr = new HandleRef(this, cPtr);
		}

		[EditorBrowsable(EditorBrowsableState.Never)]
		public static HandleRef getCPtr(OdDbSelectionSet obj)
		{
			if (obj != null)
			{
				return obj.swigCPtr;
			}
			return new HandleRef(null, IntPtr.Zero);
		}

		~OdDbSelectionSet()
		{
			this.Dispose();
		}

		public override void Dispose()
		{
			if (this.swigCPtr.Handle != IntPtr.Zero)
			{
				if (this.swigCMemOwn)
				{
					lock (this.locker)
					{
						if (this.swigCPtr.Handle != IntPtr.Zero && this.swigCMemOwn)
						{
							this.swigCMemOwn = false;
							TD_DbPINVOKE.delete_OdDbSelectionSet(this.swigCPtr);
						}
					}
					this.swigCMemOwn = false;
				}
				this.swigCPtr = new HandleRef(null, IntPtr.Zero);
			}
			GC.SuppressFinalize(this);
			base.Dispose();
		}

		public new static OdDbSelectionSet cast(OdRxObject pObj)
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = TD_DbPINVOKE.OdDbSelectionSet_cast(OdRxObject.getCPtr(pObj));
			OdDbSelectionSet result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdDbSelectionSet)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdDbSelectionSet)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdDbSelectionSet)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new static OdRxClass desc()
		{
			OdRxClass result = (OdRxClass)Teigha.Core.Helpers.odrxCreateObjectInternal(TD_DbPINVOKE.OdDbSelectionSet_desc(), false);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual OdRxClass isA()
		{
			OdRxClass result = (OdRxClass)Teigha.Core.Helpers.odrxCreateObjectInternal(TD_DbPINVOKE.OdDbSelectionSet_isA(this.swigCPtr), false);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual OdRxObject queryX(OdRxClass protocolClass)
		{
			OdRxObject result = Teigha.Core.Helpers.odrxCreateObjectInternal(TD_DbPINVOKE.OdDbSelectionSet_queryX(this.swigCPtr, OdRxClass.getCPtr(protocolClass)), false);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new static OdDbSelectionSet createObject()
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = TD_DbPINVOKE.OdDbSelectionSet_createObject__SWIG_0();
			OdDbSelectionSet result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdDbSelectionSet)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdDbSelectionSet)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdDbSelectionSet)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public static OdDbSelectionSet createObject(OdDbDatabase pDb)
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = TD_DbPINVOKE.OdDbSelectionSet_createObject__SWIG_1(OdDbDatabase.getCPtr(pDb));
			OdDbSelectionSet result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdDbSelectionSet)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdDbSelectionSet)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdDbSelectionSet)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual OdDbDatabase database()
		{
			OdDbDatabase result = (OdDbDatabase)Teigha.Core.Helpers.odrxCreateObjectInternal(TD_DbPINVOKE.OdDbSelectionSet_database(this.swigCPtr), false);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual OdDbObjectIdArray objectIdArray()
		{
			OdDbObjectIdArray result = new OdDbObjectIdArray(TD_DbPINVOKE.OdDbSelectionSet_objectIdArray(this.swigCPtr), false);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public static OdDbSelectionSet select(OdDbDatabase pDb, OdRxObject pFilter)
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = TD_DbPINVOKE.OdDbSelectionSet_select__SWIG_0(OdDbDatabase.getCPtr(pDb), OdRxObject.getCPtr(pFilter));
			OdDbSelectionSet result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdDbSelectionSet)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdDbSelectionSet)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdDbSelectionSet)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public static OdDbSelectionSet select(OdDbDatabase pDb)
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = TD_DbPINVOKE.OdDbSelectionSet_select__SWIG_1(OdDbDatabase.getCPtr(pDb));
			OdDbSelectionSet result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdDbSelectionSet)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdDbSelectionSet)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdDbSelectionSet)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public static OdDbSelectionSet select(OdDbObjectId vpId, OdGePoint3d[] nPoints, OdDbVisualSelection.Mode mode, OdDbVisualSelection.SubentSelectionMode sm, OdRxObject pFilter)
		{
			IntPtr intPtr = Teigha.Core.Helpers.MarshalPoint3dArray(nPoints);
			OdDbSelectionSet result;
			try
			{
				MemoryManager memoryManager = MemoryManager.GetMemoryManager();
				MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
				IntPtr p = TD_DbPINVOKE.OdDbSelectionSet_select__SWIG_2(OdDbObjectId.getCPtr(vpId), intPtr, (int)mode, (int)sm, OdRxObject.getCPtr(pFilter));
				OdDbSelectionSet odDbSelectionSet;
				if (currentTransaction != null)
				{
					currentTransaction.AddObject((OdDbSelectionSet)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
					odDbSelectionSet = (OdDbSelectionSet)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
				}
				else
				{
					odDbSelectionSet = (OdDbSelectionSet)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
				}
				if (TD_DbPINVOKE.SWIGPendingException.Pending)
				{
					throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
				}
				result = odDbSelectionSet;
			}
			finally
			{
				Marshal.FreeCoTaskMem(intPtr);
			}
			return result;
		}

		public static OdDbSelectionSet select(OdDbObjectId vpId, OdGePoint3d[] nPoints, OdDbVisualSelection.Mode mode, OdDbVisualSelection.SubentSelectionMode sm)
		{
			IntPtr intPtr = Teigha.Core.Helpers.MarshalPoint3dArray(nPoints);
			OdDbSelectionSet result;
			try
			{
				MemoryManager memoryManager = MemoryManager.GetMemoryManager();
				MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
				IntPtr p = TD_DbPINVOKE.OdDbSelectionSet_select__SWIG_3(OdDbObjectId.getCPtr(vpId), intPtr, (int)mode, (int)sm);
				OdDbSelectionSet odDbSelectionSet;
				if (currentTransaction != null)
				{
					currentTransaction.AddObject((OdDbSelectionSet)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
					odDbSelectionSet = (OdDbSelectionSet)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
				}
				else
				{
					odDbSelectionSet = (OdDbSelectionSet)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
				}
				if (TD_DbPINVOKE.SWIGPendingException.Pending)
				{
					throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
				}
				result = odDbSelectionSet;
			}
			finally
			{
				Marshal.FreeCoTaskMem(intPtr);
			}
			return result;
		}

		public static OdDbSelectionSet select(OdDbObjectId vpId, OdGePoint3d[] nPoints, OdDbVisualSelection.Mode mode)
		{
			IntPtr intPtr = Teigha.Core.Helpers.MarshalPoint3dArray(nPoints);
			OdDbSelectionSet result;
			try
			{
				MemoryManager memoryManager = MemoryManager.GetMemoryManager();
				MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
				IntPtr p = TD_DbPINVOKE.OdDbSelectionSet_select__SWIG_4(OdDbObjectId.getCPtr(vpId), intPtr, (int)mode);
				OdDbSelectionSet odDbSelectionSet;
				if (currentTransaction != null)
				{
					currentTransaction.AddObject((OdDbSelectionSet)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
					odDbSelectionSet = (OdDbSelectionSet)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
				}
				else
				{
					odDbSelectionSet = (OdDbSelectionSet)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
				}
				if (TD_DbPINVOKE.SWIGPendingException.Pending)
				{
					throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
				}
				result = odDbSelectionSet;
			}
			finally
			{
				Marshal.FreeCoTaskMem(intPtr);
			}
			return result;
		}

		public static OdDbSelectionSet select(OdDbObjectId vpId, OdGePoint3d[] nPoints)
		{
			IntPtr intPtr = Teigha.Core.Helpers.MarshalPoint3dArray(nPoints);
			OdDbSelectionSet result;
			try
			{
				MemoryManager memoryManager = MemoryManager.GetMemoryManager();
				MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
				IntPtr p = TD_DbPINVOKE.OdDbSelectionSet_select__SWIG_5(OdDbObjectId.getCPtr(vpId), intPtr);
				OdDbSelectionSet odDbSelectionSet;
				if (currentTransaction != null)
				{
					currentTransaction.AddObject((OdDbSelectionSet)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
					odDbSelectionSet = (OdDbSelectionSet)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
				}
				else
				{
					odDbSelectionSet = (OdDbSelectionSet)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
				}
				if (TD_DbPINVOKE.SWIGPendingException.Pending)
				{
					throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
				}
				result = odDbSelectionSet;
			}
			finally
			{
				Marshal.FreeCoTaskMem(intPtr);
			}
			return result;
		}

		public virtual void append(OdDbObjectId entityId, OdDbSelectionMethod pMethod)
		{
			TD_DbPINVOKE.OdDbSelectionSet_append__SWIG_0(this.swigCPtr, OdDbObjectId.getCPtr(entityId), OdDbSelectionMethod.getCPtr(pMethod));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public virtual void append(OdDbObjectId entityId)
		{
			TD_DbPINVOKE.OdDbSelectionSet_append__SWIG_1(this.swigCPtr, OdDbObjectId.getCPtr(entityId));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public virtual void append(OdDbObjectIdArray entityIds, OdDbSelectionMethod pMethod)
		{
			TD_DbPINVOKE.OdDbSelectionSet_append__SWIG_2(this.swigCPtr, OdDbObjectIdArray.getCPtr(entityIds), OdDbSelectionMethod.getCPtr(pMethod));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public virtual void append(OdDbObjectIdArray entityIds)
		{
			TD_DbPINVOKE.OdDbSelectionSet_append__SWIG_3(this.swigCPtr, OdDbObjectIdArray.getCPtr(entityIds));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public virtual void append(OdDbFullSubentPath subent, OdDbSelectionMethod pMethod)
		{
			TD_DbPINVOKE.OdDbSelectionSet_append__SWIG_4(this.swigCPtr, OdDbFullSubentPath.getCPtr(subent), OdDbSelectionMethod.getCPtr(pMethod));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public virtual void append(OdDbFullSubentPath subent)
		{
			TD_DbPINVOKE.OdDbSelectionSet_append__SWIG_5(this.swigCPtr, OdDbFullSubentPath.getCPtr(subent));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public new virtual void append(OdSelectionSet pSSet)
		{
			TD_DbPINVOKE.OdDbSelectionSet_append__SWIG_6(this.swigCPtr, OdSelectionSet.getCPtr(pSSet));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public virtual void remove(OdDbObjectId entityId)
		{
			TD_DbPINVOKE.OdDbSelectionSet_remove__SWIG_0(this.swigCPtr, OdDbObjectId.getCPtr(entityId));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public virtual void remove(OdDbObjectIdArray entityIds)
		{
			TD_DbPINVOKE.OdDbSelectionSet_remove__SWIG_1(this.swigCPtr, OdDbObjectIdArray.getCPtr(entityIds));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public virtual void remove(OdDbFullSubentPath subent)
		{
			TD_DbPINVOKE.OdDbSelectionSet_remove__SWIG_2(this.swigCPtr, OdDbFullSubentPath.getCPtr(subent));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public new virtual void remove(OdSelectionSet pSSet)
		{
			TD_DbPINVOKE.OdDbSelectionSet_remove__SWIG_3(this.swigCPtr, OdSelectionSet.getCPtr(pSSet));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public virtual bool isMember(OdDbObjectId entityId)
		{
			bool result = TD_DbPINVOKE.OdDbSelectionSet_isMember__SWIG_0(this.swigCPtr, OdDbObjectId.getCPtr(entityId));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual bool isMember(OdDbFullSubentPath subent)
		{
			bool result = TD_DbPINVOKE.OdDbSelectionSet_isMember__SWIG_1(this.swigCPtr, OdDbFullSubentPath.getCPtr(subent));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual OdDbSelectionMethod method(OdDbObjectId entityId)
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = TD_DbPINVOKE.OdDbSelectionSet_method__SWIG_0(this.swigCPtr, OdDbObjectId.getCPtr(entityId));
			OdDbSelectionMethod result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdDbSelectionMethod)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdDbSelectionMethod)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdDbSelectionMethod)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual uint subentCount(OdDbObjectId entityId)
		{
			uint result = TD_DbPINVOKE.OdDbSelectionSet_subentCount(this.swigCPtr, OdDbObjectId.getCPtr(entityId));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual bool getSubentity(OdDbObjectId entityId, uint i, OdDbFullSubentPath path)
		{
			bool result = TD_DbPINVOKE.OdDbSelectionSet_getSubentity(this.swigCPtr, OdDbObjectId.getCPtr(entityId), i, OdDbFullSubentPath.getCPtr(path));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual OdDbSelectionMethod method(OdDbFullSubentPath subent)
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = TD_DbPINVOKE.OdDbSelectionSet_method__SWIG_1(this.swigCPtr, OdDbFullSubentPath.getCPtr(subent));
			OdDbSelectionMethod result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdDbSelectionMethod)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdDbSelectionMethod)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdDbSelectionMethod)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		private object locker = new object();

		private HandleRef swigCPtr;
	}
}
